home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Online / PHP / include / php / ext / standard / php_rand.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-02-26  |  2.1 KB  |  62 lines

  1. /*
  2.    +----------------------------------------------------------------------+
  3.    | PHP version 4.0                                                      |
  4.    +----------------------------------------------------------------------+
  5.    | Copyright (c) 1997-2001 The PHP Group                                |
  6.    +----------------------------------------------------------------------+
  7.    | This source file is subject to version 2.02 of the PHP license,      |
  8.    | that is bundled with this package in the file LICENSE, and is        |
  9.    | available at through the world-wide-web at                           |
  10.    | http://www.php.net/license/2_02.txt.                                 |
  11.    | If you did not receive a copy of the PHP license and are unable to   |
  12.    | obtain it through the world-wide-web, please send a note to          |
  13.    | license@php.net so we can mail you a copy immediately.               |
  14.    +----------------------------------------------------------------------+
  15.    | Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca>                       |
  16.    |          Zeev Suraski <zeev@zend.com>                                |
  17.    |          Pedro Melo <melo@ip.pt>                                     |
  18.    |                                                                      |
  19.    | Based on code from: Shawn Cokus <Cokus@math.washington.edu>          |
  20.    +----------------------------------------------------------------------+
  21.  */
  22. /* $Id: php_rand.h,v 1.8 2001/02/26 06:07:23 andi Exp $ */
  23.  
  24. #ifndef PHP_RAND_H
  25. #define    PHP_RAND_H
  26.  
  27. #include <stdlib.h>
  28.  
  29. #ifndef RAND_MAX
  30. #define RAND_MAX (1<<15)
  31. #endif
  32.  
  33. #if HAVE_LRAND48
  34. #define PHP_RAND_MAX 2147483647
  35. #else
  36. #define PHP_RAND_MAX RAND_MAX
  37. #endif
  38.  
  39. /* Define rand Function wrapper */
  40. #ifdef HAVE_RANDOM
  41. #define php_rand() random()
  42. #else
  43. #ifdef HAVE_LRAND48
  44. #define php_rand() lrand48()
  45. #else
  46. #define php_rand() rand()
  47. #endif
  48. #endif
  49.  
  50. /* Define srand Function wrapper */
  51. #ifdef HAVE_SRANDOM
  52. #define php_srand(seed) srandom((unsigned int)seed)
  53. #else
  54. #ifdef HAVE_SRAND48
  55. #define php_srand(seed) srand48((long)seed)
  56. #else
  57. #define php_srand(seed) srand((unsigned int)seed)
  58. #endif
  59. #endif
  60.  
  61. #endif    /* PHP_RAND_H */
  62.